The same name must be assigned to the “main” procedure of the program (the procedure that is called when the program is run).
The first line of each procedure is:
on <procedureName [paramList]>
Up to 9 variable parameters can be listed, separated by commas.
A procedure ends with the line:
end <procedureName>
The exit command causes the program to exit the currently executing procedure. The procedure must be named:
exit <procedureName>
The simplest type of conditional statement takes the form:
if <condition> then <action>
all on one line. “condition” represents any boolean expression (i.e., one that evaluates to “true” or “false”).
A compound if statement takes the form:
if <condition> then
<series of one or more actions>
end if
An if-then-else statement can take the form:
if <condition> then <action>
else <action>
or the form:
if <condition> then
<series of one or more actions>
else <action>
If-then-else-end if statements take the form:
if <condition> then <action>
else
<series of one or more actions>
end if
or:
if <condition> then
<series of one or more actions>
else
<series of one or more actions>
end if
The repeat command takes the form:
repeat
<series of one or more actions>
end repeat
This repeats “endlessly” unless there is an exit command in the repeat loop (or until the mouse is clicked stopping the program).
The repeat-for command takes the form:
repeat [for] <expr> [times]
<series of one or more actions>
end repeat
The words in square brackets are optional; “expr” = number, variable, or mathematical expression.
The repeat-until command takes the form:
repeat until <boolean expr>
<series of one or more actions>
end repeat
The loop repeats until the boolean expression evaluates to true.
The repeat-while command takes the form:
repeat while <boolean expr>
<series of one or more actions>
end repeat
The loop repeats until the boolean expression evaluates to false.
The repeat-with command takes the form:
repeat with <variable> = <expr> to <expr>
<series of one or more actions>
end repeat
The variable is assigned the value of the first expression, and then incremented (or decremented, if “downto” is used instead of “to”) by 1 with each loop, until it reaches the value of the second expression.
The “next repeat” command must occur within a repeat loop. It brings the program back to the beginning of the loop.
The “exit repeat” command must occur within a repeat loop. It causes the program to exit the loop.